package com.hunlian.makelove.net.api;

import android.content.Context;

import com.google.gson.Gson;
import com.hunlian.makelove.bean.PrivacySettingBean;
import com.hunlian.makelove.net.InterfaceServiceVisit;
import com.hunlian.makelove.net.ResponseCallbackListener;
import com.hunlian.makelove.net.ServiceInterfaceDef;
import com.hunlian.makelove.net.StringResponseCallbackListener;


/**
 * 隐私设置
 * @author zealjiang
 * @time 2017/5/2 15:35
 */
public class PrivacySetServiceVisit extends InterfaceServiceVisit {

	public PrivacySetServiceVisit(Context context) {
		super(context);
		setFunctionId(ServiceInterfaceDef.FUNC_ID_PRIVACY_SETTING);
	}

	// 填充参数
	public void setParamters(String id) {
		paramterData.put("userId", id);
	}

	public void getResult(final ResponseCallbackListener<PrivacySettingBean,Object> listener) {
		doPost(getParamter(), new StringResponseCallbackListener() {
			@Override
			public void onSuccess(String data) {
				//Printout.println("隐私设置 :"+data);
				Gson gson = new Gson();
                PrivacySettingBean bean = gson.fromJson(data, PrivacySettingBean.class);

				if (listener != null) {
					listener.onSuccess(bean);
				}
			}

			@Override
			public void onFailure(String errCode, String errMessage,String str) {
				if (listener != null) {
					listener.onFailure(errCode, errMessage,str);
				}
			}
		});
	}


}
